export const http = (parmas) => { 
	const baseUrl = 'http://collect.94lihai.com'
	let head = {}  
	if (!parmas.url.includes('/wxapi/UserApi/login')) {
		head['token'] = uni.getStorageSync('token')
		 //  uni.getStorage({
			// key: 'token',
			// success(res) { 
			// 	head['token'] = res.data
			// }
		// }) 
	}  
	return new Promise((resolve, reject) => { 
		wx.request({
			url: baseUrl + parmas.url,
			method: parmas.method || 'GET',
			data: parmas.data || {},
			header: head,
			dataType: parmas.dataType || "json", 
			success: (res) => {        
				if(res.data.code == 100){
					uni.showToast({
						title: '请前往登录',
						icon: 'none'
					})
					setTimeout(() => {
						uni.reLaunch({
						    url: '/pages/login/Login'
						});
					},1000)
				}  
				resolve(res.data)
			},
			fail: (err) => { 
				uni.showToast({
					title: '接口请求失败',
					icon: 'none'
				})
				reject(err)
			}
		})
	})
}
